<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <title>Using the CLI Tool - Zend Framework Manual</title>

    <link href="../css/shCore.css" rel="stylesheet" type="text/css" />
    <link href="../css/shThemeDefault.css" rel="stylesheet" type="text/css" />
    <link href="../css/styles.css" media="all" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>Zend Framework</h1>
<h2>Programmer's Reference Guide</h2>
<ul>
    <li><a href="../en/zend.tool.framework.clitool.html">Inglês (English)</a></li>
    <li><a href="../pt-br/zend.tool.framework.clitool.html">Português Brasileiro (Brazilian Portuguese)</a></li>
</ul>
<table width="100%">
    <tr valign="top">
        <td width="85%">
            <table width="100%">
                <tr>
                    <td width="25%" style="text-align: left;">
                    <a href="zend.tool.framework.introduction.html">Introduction</a>
                    </td>

                    <td width="50%" style="text-align: center;">
                        <div class="up"><span class="up"><a href="zend.tool.framework.html">Zend_Tool_Framework</a></span><br />
                        <span class="home"><a href="manual.html">Programmer's Reference Guide</a></span></div>
                    </td>

                    <td width="25%" style="text-align: right;">
                        <div class="next" style="text-align: right; float: right;"><a href="zend.tool.framework.architecture.html">Architecture</a></div>
                    </td>
                </tr>
            </table>
<hr />
<div id="zend.tool.framework.clitool" class="section"><div class="info"><h1 class="title">Using the CLI Tool</h1></div>
    

    <p class="para">
        The <acronym class="acronym">CLI</acronym>, or command line tool (internally known as the console tool),
        is currently the primary interface for dispatching <span class="classname">Zend_Tool</span>
        requests. With the <acronym class="acronym">CLI</acronym> tool, developers can issue tooling requests
        inside the &quot;command line windows&quot;, also commonly known as a &quot;terminal&quot;
        window. This environment is predominant in the *nix environment, but
        also has a common implementation in windows with the
        <var class="filename">cmd.exe</var>, console2 and also with the Cygwin project.
    </p>

    <div class="section" id="zend.tool.framework.clitool.setup-general"><div class="info"><h1 class="title">Setting up the CLI tool</h1></div>
        

        <p class="para">
            To issue tooling requests via the command line client, you first
            need to set up the client so that your system can handle the &quot;zf&quot;
            command. The command line client, for all intents and purposes, is
            the <var class="filename">.sh</var> or <var class="filename">.bat</var> file that is provided with
            your Zend Framework distribution. In trunk, it can be found here:
            <a href="http://framework.zend.com/svn/framework/standard/trunk/bin/" class="link external">&raquo; http://framework.zend.com/svn/framework/standard/trunk/bin/</a>.
        </p>

        <p class="para">
            As you can see, there are 3 files in the <var class="filename">/bin/</var>
            directory: a <var class="filename">zf.php</var>, <var class="filename">zf.sh</var>, and
            <var class="filename">zf.bat</var>. The <var class="filename">zf.sh</var> and the
            <var class="filename">zf.bat</var> are the operating system specific client
            wrappers: <var class="filename">zf.sh</var> for the *nix environment, and
            <var class="filename">zf.bat</var> for the Win32 environment. These client wrappers are
            responsible for finding the proper <var class="filename">php.exe</var>, finding the
            <var class="filename">zf.php</var>, and passing on the client request. The
            <var class="filename">zf.php</var> is the responsible for handling understanding
            your environment, constructing the proper include_path, and passing
            what is provided on the command line to the proper library component
            for dispatching.
        </p>

        <p class="para">
            Ultimately, you want to ensure two things to make everything work
            regardless of the operating system you are on:
        </p>

        <ol type="1">
            <li class="listitem">
                <p class="para">
                    <var class="filename">zf.sh/zf.bat</var> is reachable from your system
                    path. This is the ability to call <strong class="command">zf</strong> from
                    anywhere on your command line, regardless of what your
                    current working directory is.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <var class="filename">ZendFramework/library</var> is in your
                    <span class="property">include_path</span>.
                </p>
            </li>
        </ol>

        <blockquote class="note"><p><b class="note">Note</b>: 
            <p class="para">
                Note: while the above are the most ideal
                requirements, you can simply download Zend Framework and expect it
                to work as <var class="filename">./path/to/zf.php</var> some command.
            </p>
        </p></blockquote>
    </div>

    <div class="section" id="zend.tool.framework.clitool.setup-starnix"><div class="info"><h1 class="title">Setting up the CLI tool on Unix-like Systems</h1></div>
        

        <p class="para">
            The most common setup in the *nix environment, is to copy the
            <var class="filename">zf.sh</var> and <var class="filename">zf.php</var> into the same directory
            as your <acronym class="acronym">PHP</acronym> binary. This can generally be found in one of the
            following places:
        </p>

        <pre class="programlisting brush: text">
/usr/bin
/usr/local/bin
/usr/local/ZendServer/bin/
/Applications/ZendServer/bin/
</pre>


        <p class="para">
            To find out the location of your <acronym class="acronym">PHP</acronym> binary, you can execute &#039;which
            php&#039; on the command line. This will return the location of the <acronym class="acronym">PHP</acronym>
            binary you will be using to run <acronym class="acronym">PHP</acronym> scripts in this environment.
        </p>

        <p class="para">
            The next order of business is to ensure that Zend Framework
            library is set up correctly inside of the system <acronym class="acronym">PHP</acronym>
            <span class="property">include_path</span>. To find out where your
            <span class="property">include_path</span> is located, you can execute <strong class="command">php -i</strong>
            and look for the <span class="property">include_path</span> variable, or more succinctly,
            execute <strong class="command">php -i | grep include_path</strong>. Once you have found where
            your <span class="property">include_path</span> is located (this will generally be
            something like <var class="filename">/usr/lib/php</var>, <var class="filename">/usr/share/php</var>,
            <var class="filename">/usr/local/lib/php</var>, or similar), ensure that the contents of the
            <var class="filename">/library/</var> directory are put
            inside your <span class="property">include_path</span> specified directory.
        </p>

        <p class="para">
            Once you have done those two things, you should be able to issue a
            command and get back the proper response like this:
        </p>

        <p class="para">
            <div class="inlinemediaobject"><div class="imageobject"><a href="images/d481d625821a97b9a5eb2cec99dca50e-zend.tool.framework.cliversionunix.png"><img src="images/d481d625821a97b9a5eb2cec99dca50e-zend.tool.framework.cliversionunix.png" alt="zend.tool.framework.cliversionunix.png" width="450" height="247" /></a></div></div>
        </p>

        <p class="para">
            If you do not see this type of output, go back and check your setup
            to ensure you have all of the necessary pieces in the proper place.
        </p>

        <p class="para">
            There are a couple of alternative setups you might want to employ
            depending on your servers configuration, your level of access, or
            for other reasons.
        </p>

        <p class="para">
            <em class="emphasis">Alternative Setup</em> involves keeping the Zend
            Framework download together as is, and creating a link from a <b><tt>PATH</tt></b>
            location to the <var class="filename">zf.sh</var>. What this means is you can
            place the contents of the ZendFramework download into a location
            such as <var class="filename">/usr/local/share/ZendFramework</var>, or more locally
            like <var class="filename">/home/username/lib/ZendFramework</var>, and creating a
            symbolic link to the <var class="filename">zf.sh</var>.
        </p>

        <p class="para">
            Assuming you want to put the link inside <var class="filename">/usr/local/bin</var>
            (this could also work for placing the link inside
            <var class="filename">/home/username/bin/</var> for example) you would issue a
            command similar to this:
        </p>

        <pre class="programlisting brush: sh">
ln -s /usr/local/share/ZendFramework/bin/zf.sh /usr/local/bin/zf

# OR (for example)
ln -s /home/username/lib/ZendFramework/bin/zf.sh /home/username/bin/zf
</pre>


        <p class="para">
            This will create a link which you should be able to access globally
            on the command line.
        </p>
    </div>

    <div class="section" id="zend.tool.framework.clitool.setup-windows"><div class="info"><h1 class="title">Setting up the CLI tool on Windows</h1></div>
        

        <p class="para">
            The most common setup in the Windows Win32 environment, is to copy
            the <var class="filename">zf.bat</var> and <var class="filename">zf.php</var> into the same
            directory as your <acronym class="acronym">PHP</acronym> binary. This can generally be found in one of
            the following places:
        </p>

        <pre class="programlisting brush: text">
C:\PHP
C:\Program Files\ZendServer\bin\
C:\WAMP\PHP\bin
</pre>


        <p class="para">
            You should be able to run <var class="filename">php.exe</var> on the command line.
            If you are not able to, first check the documentation that came with
            your <acronym class="acronym">PHP</acronym> distribution, or ensure that the path to
            <var class="filename">php.exe</var> is in your
            Windows <b><tt>PATH</tt></b> environment variable.
        </p>

        <p class="para">
            The next order of business is to ensure that Zend Framework
            library is set up correctly inside of the system <acronym class="acronym">PHP</acronym>
            <span class="property">include_path</span>. To find out where your
            <span class="property">include_path</span> is located, you can type <strong class="command">php -i</strong> and
            look for the <span class="property">include_path</span> variable, or more succinctly
            execute <strong class="command">php -i | grep include_path</strong> if you have Cygwin setup with
            grep available. Once you have found where your
            <span class="property">include_path</span> is located (this will generally be
            something like <var class="filename">C:\PHP\pear</var>, <var class="filename">C:\PHP\share</var>,
            <var class="filename">C:\Program%20Files\ZendServer\share</var> or similar), ensure
            that the contents of the library/ directory are put inside your
            <span class="property">include_path</span> specified directory.
        </p>

        <p class="para">
            Once you have done those two things, you should be able to issue a
            command and get back the proper response like this:
        </p>

        <p class="para">
            <div class="inlinemediaobject"><div class="imageobject"><a href="images/d481d625821a97b9a5eb2cec99dca50e-zend.tool.framework.cliversionwin32.png"><img src="images/d481d625821a97b9a5eb2cec99dca50e-zend.tool.framework.cliversionwin32.png" alt="zend.tool.framework.cliversionwin32.png" width="450" height="306" /></a></div></div>
        </p>

        <p class="para">
            If you do not see this type of output, go back and check your setup
            to ensure you have all of the necessary pieces in the proper place.
        </p>

        <p class="para">
            There are a couple of alternative setups you might want to employ
            depending on your server&#039;s configuration, your level of access, or
            for other reasons.
        </p>

        <p class="para">
            <em class="emphasis">Alternative Setup</em> involves keeping the Zend
            Framework download together as is, and altering both your system
            <b><tt>PATH</tt></b> as well as the <var class="filename">php.ini</var> file.
            In your user&#039;s environment, make sure to add
            <var class="filename">C:\Path\To\ZendFramework\bin</var>, so that your
            <var class="filename">zf.bat</var> file is executable. Also, alter the
            <var class="filename">php.ini</var> file to ensure that
            <var class="filename">C:\Path\To\ZendFramework\library</var> is in your
            <span class="property">include_path</span>.
        </p>
    </div>

    <div class="section" id="zend.tool.framework.clitool.setup-othernotes"><div class="info"><h1 class="title">Other Setup Considerations</h1></div>
        

        <p class="para">
            If for some reason you do not want Zend Framework library inside
            your <span class="property">include_path</span>, there is another option. There are
            two special environment variables that <var class="filename">zf.php</var> will
            utilize to determine the location of your Zend Framework
            installation.
        </p>

        <p class="para">
            The first is <b><tt>ZEND_TOOL_INCLUDE_PATH_PREPEND</tt></b>, which will
            prepend the value of this environment variable to the system
            (<var class="filename">php.ini</var>) <span class="property">include_path</span> before loading the
            client.
        </p>

        <p class="para">
            Alternatively, you might want to use
            <b><tt>ZEND_TOOL_INCLUDE_PATH</tt></b> to completely
            <em class="emphasis">replace</em> the system <span class="property">include_path</span>
            for one that makes sense specifically for the <strong class="command">zf</strong>
            command line tool.
        </p>
    </div>

    <div class="section" id="zend.tool.framework.clitool.continuing"><div class="info"><h1 class="title">Where To Go Next?</h1></div>
        

        <p class="para">
            At this point, you should be set up to start initiating some more
            &quot;interesting&quot; commands. To get going, you can issue the
            <strong class="command">zf --help</strong> command to see what is available to you.
        </p>

        <p class="para">
            <div class="inlinemediaobject"><div class="imageobject"><a href="images/d481d625821a97b9a5eb2cec99dca50e-zend.tool.framework.clihelp.png"><img src="images/d481d625821a97b9a5eb2cec99dca50e-zend.tool.framework.clihelp.png" alt="zend.tool.framework.clihelp.png" width="450" height="288" /></a></div></div>
        </p>

        <p class="para">
            Continue on to the <span class="classname">Zend_Tool_Project</span> &quot;Create Project&quot;
            section to understand how to use the <strong class="command">zf</strong> script for
            project creation.
        </p>
    </div>
</div>
        <hr />

            <table width="100%">
                <tr>
                    <td width="25%" style="text-align: left;">
                    <a href="zend.tool.framework.introduction.html">Introduction</a>
                    </td>

                    <td width="50%" style="text-align: center;">
                        <div class="up"><span class="up"><a href="zend.tool.framework.html">Zend_Tool_Framework</a></span><br />
                        <span class="home"><a href="manual.html">Programmer's Reference Guide</a></span></div>
                    </td>

                    <td width="25%" style="text-align: right;">
                        <div class="next" style="text-align: right; float: right;"><a href="zend.tool.framework.architecture.html">Architecture</a></div>
                    </td>
                </tr>
            </table>
</td>
        <td style="font-size: smaller;" width="15%"> <style type="text/css">
#leftbar {
	float: left;
	width: 186px;
	padding: 5px;
	font-size: smaller;
}
ul.toc {
	margin: 0px 5px 5px 5px;
	padding: 0px;
}
ul.toc li {
	font-size: 85%;
	margin: 1px 0 1px 1px;
	padding: 1px 0 1px 11px;
	list-style-type: none;
	background-repeat: no-repeat;
	background-position: center left;
}
ul.toc li.header {
	font-size: 115%;
	padding: 5px 0px 5px 11px;
	border-bottom: 1px solid #cccccc;
	margin-bottom: 5px;
}
ul.toc li.active {
	font-weight: bold;
}
ul.toc li a {
	text-decoration: none;
}
ul.toc li a:hover {
	text-decoration: underline;
}
</style>
 <ul class="toc">
  <li class="header home"><a href="manual.html">Programmer's Reference Guide</a></li>
  <li class="header up"><a href="manual.html">Programmer's Reference Guide</a></li>
  <li class="header up"><a href="reference.html">Zend Framework Reference</a></li>
  <li class="header up"><a href="zend.tool.framework.html">Zend_Tool_Framework</a></li>
  <li><a href="zend.tool.framework.introduction.html">Introduction</a></li>
  <li class="active"><a href="zend.tool.framework.clitool.html">Using the CLI Tool</a></li>
  <li><a href="zend.tool.framework.architecture.html">Architecture</a></li>
  <li><a href="zend.tool.framework.writing-providers.html">Creating Providers to use with Zend_Tool_Framework</a></li>
  <li><a href="zend.tool.framework.system-providers.html">Shipped System Providers</a></li>
  <li><a href="zend.tool.framework.extending.html">Extending and Configuring Zend_Tool_Framework</a></li>
 </ul>
 </td>
    </tr>
</table>

<script type="text/javascript" src="../js/shCore.js"></script>
<script type="text/javascript" src="../js/shAutoloader.js"></script>
<script type="text/javascript" src="../js/main.js"></script>

</body>
</html>